<?php

class ContatoController extends Site_Controller_Action
{
    public function init()
    {
        $this->body_class = 'no-sidebar';
    }

    public function indexAction()
    {
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/mapa.js');

        $this->view->headLink()->prependStylesheet($this->_urlbase.'/public/media/js/bootstrap/dist/css/bootstrap-theme.min.css');
        $this->view->headLink()->prependStylesheet($this->_urlbase.'/public/media/css/bootstrap.tooltip.css');
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/bootstrap/dist/js/bootstrap.min.js');

        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/jquery.maskedinput.min.js');
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/jquery.maskMoney.min.js');
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/mask.js');

        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/validation/dist/jquery.validate.min.js');
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/view/contato.js');

    }
    
    public function contatoAction()
    {
        $this->_helper->layout->disableLayout(); 
        $this->_helper->viewRenderer->setNoRender();
        
        $ok = false;
        
        if($this->getRequest()->isPost()) {
            try {
                $formData = $this->getRequest()->getPost();

                Zend_Loader::loadClass('envioemail','library');
                $arr['nome'] = $formData['nome'];
                $arr['email'] = $formData['email'];
                $arr['telefone'] = $formData['telefone'];
                $arr['assunto'] = $formData['assunto'];
                $arr['mensagem'] = $formData['mensagem'];
                $arr['urlbase']  = $this->_urlbase;
                $arr['modulo'] = '';//contato';
                $ok = envioemail::formularioContato($arr); 
                
            } catch (Exception $exc) {
                //echo 'error: '.$exc->getMessage(); 
            }
        }
        
        echo json_encode(array('ok' => $ok));
        
    }
    
}

